Imports DotNetNuke.Entities.Portals

Namespace DotNetNuke.Modules.ProjectTracker

    Public Class Utils

        Public Function FormatTimeSpan(ByVal ts As TimeSpan) As String
            Dim s As String = ""
            If ts.Days > 0 Then
                s = ts.Days.ToString() & CType(IIf(ts.Days = 1, " day", " days"), String)
            End If
            If ts.Hours > 0 Then
                s = CType(IIf(s <> "", s & ", " & ts.Hours.ToString() & CType(IIf(ts.Hours = 1, " hour", " hours"), String), ts.Hours.ToString() & CType(IIf(ts.Hours = 1, " hour", " hours"), String)), String)
            End If
            If ts.Minutes > 0 Then
                s = CType(IIf(s <> "", s & " and " & ts.Minutes.ToString() & CType(IIf(ts.Minutes = 1, " minute", " minutes"), String), ts.Minutes.ToString() & CType(IIf(ts.Minutes = 1, " minute", " minutes"), String)), String)
            End If
            s = s & " ago"
            If s <> " ago" Then
                Return s
            End If
            s = "just moments ago"
            Return s
        End Function

    End Class

End Namespace
